﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq.Mapping;
using QuanLyPhongMach.Platform;

namespace QuanLyPhongMach.Model
{
    [Table (Name="BenhNhan")]
    public class CBenhNhan
    {
        #region Properties
        [Column(Name = "MaBenhNhan", IsPrimaryKey = true)]
        public int MaBenhNhan { get; set; }

        [Column(Name = "HoTen")]
        public string HoTen { get; set; }

        [Column(Name = "GioiTinh",UpdateCheck=UpdateCheck.Never)]
        public bool GioiTinh { get; set; }

        [Column(Name = "NamSinh")]
        public DateTime NamSinh {get; set; }

        public string ShortNamSinh
        {
            get { return NamSinh.ToShortDateString(); }
            private set { }
        }

        [Column(Name = "DiaChi")]
        public string DiaChi { get; set; }

        public string StringGioiTinh 
        {
            get
            {
                if (GioiTinh)
                {
                    return CConstant.NAM;
                }
                else
                    return CConstant.NU;
            }
            set
            {
                if (value == CConstant.NAM)
                {
                    GioiTinh = true;
                }
                else
                {
                    GioiTinh = false;
                }
            }
        }
        #endregion

        #region Constructor
        public CBenhNhan()
        { 
        }

        public CBenhNhan(string hoten, bool gioitinh, DateTime namsinh, string diachi)
        {
            Initialize(hoten, gioitinh, namsinh, diachi);
        }

        public CBenhNhan(int mabenhnhan, string hoten, bool gioitinh, DateTime namsinh, string diachi)
        {
            Initialize(hoten, gioitinh, namsinh, diachi);
            this.MaBenhNhan = mabenhnhan;
        }

        public void Initialize(string hoten, bool gioitinh, DateTime namsinh, string diachi)
        {
            this.HoTen = hoten;
            this.GioiTinh = gioitinh;
            this.NamSinh = namsinh;
            this.DiaChi = diachi;
        }
        #endregion
    }
}
